﻿<Window x:Class="Morphine.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Morphine" Width="640"  Height="480" MinWidth="470" MinHeight="170" Background="Transparent" WindowStartupLocation="CenterScreen"
        SourceInitialized="WindowSourceInitialized" Closed="WindowClosed">
    <Window.Resources>
        <Storyboard x:Key="ShowAlbumBgAnim">
            <DoubleAnimation Storyboard.TargetName="AlbumCoverBg" Storyboard.TargetProperty="Opacity" From="0" To="0.7" Duration="0:0:1.2"/>
        </Storyboard>
        <Storyboard x:Key="SwitchAlbumCoverAnim" Completed="SwitchAlbumCoverAnimCompleted" FillBehavior="Stop">
            <DoubleAnimation Storyboard.TargetName="OldAlbumGrad1" Storyboard.TargetProperty="Offset" From="0" To="1" Duration="0:0:0.5" BeginTime="0:0:0.1" DecelerationRatio="0.3"/>
            <DoubleAnimation Storyboard.TargetName="OldAlbumGrad2" Storyboard.TargetProperty="Offset" From="0.01" To="1" Duration="0:0:0.5" DecelerationRatio="0.3"/>
        </Storyboard>
    </Window.Resources>
    <Window.ContextMenu>
        <ContextMenu>
            <MenuItem Name="OpenItem" Header="Open..." Click="OpenItemClick"/>
            <MenuItem Name="MinimodeItem" Header="Switch to mini mode" Click="MiniModeItemClick"/>
            <MenuItem Name="CloseItem" Header="Close" Click="CloseItemClick"/>
        </ContextMenu>
    </Window.ContextMenu>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="2"/>
            <ColumnDefinition x:Name="PlayListColumnDefinition" Width="200" MinWidth="50"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
        <Grid Name="MainBarGrid" Grid.ColumnSpan="3" Grid.Row="1" Margin="0,-4,0,4">
            <Path Data="{StaticResource mainbar_bg_pathdata}" Height="48" Width="359"  Stroke="#66FFFFFF" HorizontalAlignment="Center" Stretch="Uniform"/>
            <Path Data="{StaticResource mainbar_bg_pathdata}" Height="46" Width="357" Stroke="#66000000" HorizontalAlignment="Center" Fill="#40C1C1C1" Margin="0,0,0,2" Stretch="Uniform"/>
            <ToggleButton Name="PlayButton" Width="44" Height="44" Margin="0,-12,0,0" Template="{StaticResource play_button_template}" IsEnabled="False" Click="PlayButtonClick" Background="#0485c3"/>
            <Button Name="PrevButton" Width="52" Height="22" Margin="0,-12,98,0" Template="{StaticResource prev_button_template}" IsEnabled="False" Click="PrevButtonClick"/>
            <Button Name="NextButton" Width="52" Height="22" Margin="98,-12,0,0" Template="{StaticResource next_button_template}" IsEnabled="False" Click="NextButtonClick"/>
            <Slider Name="VolumeSlider" HorizontalAlignment="Center" Width="70" Margin="135,-13,-135,0" Cursor="Hand" IsMoveToPointEnabled="True"
                    VerticalAlignment="Center" ValueChanged="VolumeSliderValueChanged" Maximum="100" Style="{StaticResource VolumeSliderStyle}" AutoToolTipPlacement="TopLeft" SmallChange="1" LargeChange="10" />
            <Button Name="StopButton" Width="14" Height="13" Template="{StaticResource StopButton}" VerticalAlignment="Center" HorizontalAlignment="Center"
                    Margin="-90,-12,90,0" Click="StopButtonClick" IsEnabled="False"/>
            <ToggleButton Name="ShuffleButton" Width="24" Height="22" HorizontalAlignment="Center" Margin="-125,-13,125,0" Click="ShuffleButtonClick">
                <ToggleButton.Template>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Image Name="Image" Source="/Morphine.UI;component/Resources/shuffle_icon_normal.png"/>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter TargetName="Image" Property="Source" Value="/Morphine.UI;component/Resources/shuffle_icon_pressed.png" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </ToggleButton.Template>
            </ToggleButton>
        </Grid>
        <Grid Name="PlaylistGrid" Grid.Column="2">
            <Rectangle>
                <Rectangle.Fill>
                    <ImageBrush ImageSource="/Morphine.UI;component/Resources/playlist_bg.png" TileMode="Tile" Stretch="Fill" Viewbox="0,0,200,200" Viewport="0,0,200,200" ViewportUnits="Absolute" ViewboxUnits="Absolute" />
                </Rectangle.Fill>
            </Rectangle>
            <TextBlock Name="PlaylistTitleTextBlock" FontFamily="Segoe UI" FontWeight="Light" FontSize="20" VerticalAlignment="Top" Margin="10" TextTrimming="CharacterEllipsis" Foreground="#c1c1c1" HorizontalAlignment="Center"/>
            <ListBox Name="Playlist" Background="Transparent" BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                     HorizontalContentAlignment="Stretch" ItemContainerStyle="{StaticResource PlaylistItemStyle}" Margin="-2,40,-2,0">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <DockPanel MouseLeftButtonDown="PlayListItemMouseLeftButtonDown">
                            <TextBlock DockPanel.Dock="Right" FontFamily="Segoe UI" FontSize="12" Foreground="#c1c1c1" Text="{Binding Duration, Mode=OneTime}" FontWeight="Light" VerticalAlignment="Center"/>
                            <TextBlock TextTrimming="CharacterEllipsis" FontFamily="Segoe UI" FontSize="14" Foreground="White" FontWeight="Light" Margin="0,0,5,0">
                                <Run Text="{Binding Title, Mode=OneTime}" Foreground="White"/>
                                <Run Text=" - " Foreground="#c1c1c1"/>
                                <Run Text="{Binding Artist, Mode=OneTime}" Foreground="#c1c1c1"/>
                            </TextBlock>
                        </DockPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <Rectangle Width="6" HorizontalAlignment="Left" Opacity="0.3">
                <Rectangle.Fill>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                        <GradientStop Color="Black" Offset="0"/>
                        <GradientStop Color="#00000000" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <Rectangle Height="4" VerticalAlignment="Top" Opacity="0.2">
                <Rectangle.Fill>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Color="Black" Offset="0"/>
                        <GradientStop Color="#00000000" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <Rectangle Height="4" VerticalAlignment="Bottom" Opacity="0.2">
                <Rectangle.Fill>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Color="Black" Offset="1"/>
                        <GradientStop Color="#00000000" Offset="0"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
        </Grid>
        <Grid Name="ViewportGrid" Margin="0,0,0,0">
            <Rectangle Fill="Black"/>
            <StackPanel Orientation="Vertical" Margin="0,70,0,-70" VerticalAlignment="Center" SnapsToDevicePixels="True">
                <Rectangle Height="1" Fill="Black"/>
                <Rectangle Height="1" Fill="#1a1a1a"/>
            </StackPanel>
            <Image Name="AlbumCoverBg" Source="{Binding ElementName=AlbumCover, Path=Source}" Width="320" Height="260" Margin="0,-60,0,0" Opacity="0" Stretch="Fill">
                <Image.Effect>
                    <BlurEffect Radius="150" RenderingBias="Performance" />
                </Image.Effect>
            </Image>
            <StackPanel Orientation="Vertical"  Margin="20,20,0,20">
                <TextBlock Name="MediaTitleTextBlock" VerticalAlignment="Top" HorizontalAlignment="Left" Text="" FontFamily="Segoe UI" 
                       FontWeight="Light" FontSize="30" Foreground="White" TextTrimming="CharacterEllipsis"/>
                <TextBlock Name="ArtistNameTextBlock" VerticalAlignment="Top" HorizontalAlignment="Left" Text="" FontFamily="Segoe UI" 
                       FontWeight="Light" FontSize="20" Foreground="White" TextTrimming="CharacterEllipsis" Margin="0,10,0,0"/>
                <TextBlock Name="AlbumTitleTextBlock" VerticalAlignment="Top" HorizontalAlignment="Left" Text="" FontFamily="Segoe UI" 
                       FontWeight="Light" FontSize="16" Foreground="White" TextTrimming="CharacterEllipsis"/>
            </StackPanel>
            <TextBlock Name="TimeEstimatedTextBlock" VerticalAlignment="Center" HorizontalAlignment="Right" Text="" Foreground="#898989" FontSize="36" FontFamily="Segoe UI" FontWeight="Light" Margin="0,0,10,-100" Opacity="0.7"/>
            <Image Name="AlbumCoverShadow" Source="/Morphine.UI;component/Resources/albumcover_shadow.png" Width="220" Height="210" Margin="0,0,0,7"/>
            <StackPanel Orientation="Vertical" VerticalAlignment="Center" Margin="0,0,0,-60">
                <Image Name="AlbumCover" Width="200" Height="200" Stretch="Fill"/>
                <Path Name="AlbumCoverReflection" Data="{StaticResource albumcover_reflection_pathdata}" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Path.Fill>
                        <VisualBrush>
                            <VisualBrush.Visual>
                                <Image Source="{Binding ElementName=AlbumCover, Path=Source}">
                                    <Image.RenderTransform>
                                        <ScaleTransform ScaleY="-1"/>
                                    </Image.RenderTransform>
                                    <Image.OpacityMask>
                                        <LinearGradientBrush StartPoint="0,1" EndPoint="0,0">
                                            <GradientStop Color="#4C000000" Offset="0"/>
                                            <GradientStop Color="#00000000" Offset="0.4"/>
                                        </LinearGradientBrush>
                                    </Image.OpacityMask>
                                </Image>
                            </VisualBrush.Visual>
                        </VisualBrush>
                    </Path.Fill>
                </Path>
            </StackPanel>
            <Image Name="OldAlbumCover" Width="200" Height="200">
                <Image.OpacityMask>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop x:Name="OldAlbumGrad1" Color="#00000000" Offset="0"/>
                        <GradientStop x:Name="OldAlbumGrad2" Color="#FF000000" Offset="0.01"/>
                        <GradientStop Color="#FF000000" Offset="1"/>
                    </LinearGradientBrush>
                </Image.OpacityMask>
            </Image>
        </Grid>
        <Grid Grid.Column="1" SnapsToDevicePixels="True">
            <Rectangle HorizontalAlignment="Left" Width="1" Fill="#595959"/>
            <Rectangle HorizontalAlignment="Right" Width="1" Fill="Black"/>
        </Grid>
        <GridSplitter Background="#00000000" Grid.Column="1" Grid.Row="0" Height="Auto" Width="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
        <Slider Name="PositionSlider" Grid.ColumnSpan="3" Grid.RowSpan="2" Cursor="Hand" VerticalAlignment="Bottom" Style="{StaticResource PositionSliderStyle}"
                IsMoveToPointEnabled="True" Margin="0,0,0,47" IsEnabled="False" ValueChanged="PositionSliderValueChanged"/>
    </Grid>
</Window>
